//! Sport state machine tests
//!
//! This module contains tests for the sport state machine functionality.

use unitree_ros2_rs::sport_client::state_machine::SportState;

#[test]
fn test_from_error_code() {
    assert_eq!(SportState::from_error_code(100), Some(SportState::Agile));
    assert_eq!(SportState::from_error_code(1004), Some(SportState::Squat));
    assert_eq!(SportState::from_error_code(2006), Some(SportState::Squat));
    assert_eq!(SportState::from_error_code(9999), None);
}

#[test]
fn test_to_error_code() {
    assert_eq!(SportState::Agile.to_error_code(), 100);
    assert_eq!(SportState::Squat.to_error_code(), 1004);
}

#[test]
fn test_all_error_codes() {
    assert_eq!(SportState::Agile.all_error_codes(), vec![100]);
    assert_eq!(SportState::Squat.all_error_codes(), vec![1004, 2006]);
}

#[test]
fn test_matches_error_code() {
    assert!(SportState::Squat.matches_error_code(1004));
    assert!(SportState::Squat.matches_error_code(2006));
    assert!(!SportState::Squat.matches_error_code(1001));
}